package rad.framework.mda.generator.template.main.java.seam;

import java.util.*;
import org.eclipse.uml2.uml.*;
import rad.framework.mda.generator.util.*;
import org.eclipse.emf.codegen.util.*;

public class Editor
{
  protected static String nl;
  public static synchronized Editor create(String lineSeparator)
  {
    nl = lineSeparator;
    Editor result = new Editor();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "";
  protected final String TEXT_2 = "/*" + NL + " * ============================================================================" + NL + " *                   GNU Lesser General Public License" + NL + " * ============================================================================" + NL + " */" + NL + "package ";
  protected final String TEXT_3 = ".editor;";
  protected final String TEXT_4 = NL;
  protected final String TEXT_5 = NL;
  protected final String TEXT_6 = NL + NL + "/**" + NL + " * The local interface for a CRUD user interface." + NL + " *" + NL + " * @author ";
  protected final String TEXT_7 = NL + " * @generated" + NL + " */";
  protected final String TEXT_8 = NL + "@Local" + NL + "public interface ";
  protected final String TEXT_9 = "Editor extends AbstractEditor< ";
  protected final String TEXT_10 = " > {";
  protected final String TEXT_11 = NL + "public interface ";
  protected final String TEXT_12 = "Editor<E extends ";
  protected final String TEXT_13 = "> extends AbstractEditor< E > {";
  protected final String TEXT_14 = NL + "public interface ";
  protected final String TEXT_15 = "Editor<E extends ";
  protected final String TEXT_16 = "> ";
  protected final String TEXT_17 = "< E > {";
  protected final String TEXT_18 = NL + "@Local" + NL + "public interface ";
  protected final String TEXT_19 = "Editor ";
  protected final String TEXT_20 = "< ";
  protected final String TEXT_21 = " > {";
  protected final String TEXT_22 = NL;
  protected final String TEXT_23 = NL + "\t/** @generated */" + NL + "\tRootTreeNode init";
  protected final String TEXT_24 = "Tree();" + NL + "\t" + NL + "\t/** @generated */" + NL + "\t";
  protected final String TEXT_25 = " init";
  protected final String TEXT_26 = "();";
  protected final String TEXT_27 = NL + NL + "\t//------------------------------------------------------------------------" + NL + "\t//--- ";
  protected final String TEXT_28 = NL + "\t//------------------------------------------------------------------------\t";
  protected final String TEXT_29 = NL + NL + "\t/** @generated */" + NL + "\tString ";
  protected final String TEXT_30 = "();";
  protected final String TEXT_31 = NL + "}";
  protected final String TEXT_32 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    

    org.eclipse.uml2.uml.Class uml2Class = (org.eclipse.uml2.uml.Class) argument;org.eclipse.uml2.uml.Package uml2Package = uml2Class.getPackage();
    stringBuffer.append(TEXT_1);
    stringBuffer.append(TEXT_2);
    stringBuffer.append(NameHelper.getQualifiedName(uml2Package));
    stringBuffer.append(TEXT_3);
    ImportManager importManager = ImportHelper.makeImportManager("");
    stringBuffer.append(TEXT_4);
    importManager.addImport("javax.ejb.Local");
    importManager.addImport("rad.framework.seam.AbstractEditor");
    importManager.addImport("rad.framework.richfaces.RootTreeNode");
    stringBuffer.append(TEXT_5);
    ImportHelper.addImport(uml2Class);
    
StringBuffer importStringBuffer = stringBuffer;
int importInsertionPoint = stringBuffer.length();
importManager.addCompilationUnitImports(stringBuffer.toString());

    stringBuffer.append(TEXT_6);
    stringBuffer.append(System.getProperty("user.name"));
    stringBuffer.append(TEXT_7);
    if (!ClassHelper.hasSubclasses(uml2Class) && !ClassHelper.hasSuperClass(uml2Class)) {
    stringBuffer.append(TEXT_8);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_9);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_10);
    } else if (ClassHelper.hasSubclasses(uml2Class) && !ClassHelper.hasSuperClass(uml2Class)) {
    stringBuffer.append(TEXT_11);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_12);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_13);
    } else if (ClassHelper.hasSubclasses(uml2Class)) {
    stringBuffer.append(TEXT_14);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_15);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_16);
    stringBuffer.append(ClassHelper.getExtends(uml2Class, "Editor"));
    stringBuffer.append(TEXT_17);
    } else {
    stringBuffer.append(TEXT_18);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_19);
    stringBuffer.append(ClassHelper.getExtends(uml2Class, "Editor"));
    stringBuffer.append(TEXT_20);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_21);
    }
    stringBuffer.append(TEXT_22);
    if (!ClassHelper.hasSubclasses(uml2Class)) {
    stringBuffer.append(TEXT_23);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_24);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_25);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_26);
    }
    Region r = ClassHelper.getRegion(uml2Class);
    if (r != null) {
    stringBuffer.append(TEXT_27);
    stringBuffer.append(NameHelper.getCapName(r));
    stringBuffer.append(TEXT_28);
    for (Iterator<Transition> k=ClassHelper.getTransitions(r); k.hasNext();) { Transition t = k.next();
    stringBuffer.append(TEXT_29);
    stringBuffer.append(t.getName());
    stringBuffer.append(TEXT_30);
    }}
    stringBuffer.append(TEXT_31);
    importStringBuffer.insert(importInsertionPoint, importManager.computeSortedImports());
    stringBuffer.append(TEXT_32);
    return stringBuffer.toString();
  }
}
